﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using LearnThemselvesEffectively.Classes;

namespace LearnThemselvesEffectively.Forms
{
    /// <summary>
    /// Interaction logic for frmProxyOptions.xaml
    /// </summary>
    public partial class frmProxyOptions : Window
    {
        Point moDownPoint;
        bool moAllowMoveWindow;

        public frmProxyOptions()
        {
            InitializeComponent();
            ProxyOption.LanguageDirection = ProxyOption.eLanguageDirection.PolEng;
            this.rdbAllWords.Checked += new RoutedEventHandler(this.rdbWordAmount_CheckedChange);
            this.rdbDificultWords.Checked += new RoutedEventHandler(this.rdbWordAmount_CheckedChange);
            this.rdbNotLearnedWords.Checked += new RoutedEventHandler(this.rdbWordAmount_CheckedChange);
        }

        private void StackPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            moDownPoint = new Point(Mouse.GetPosition(this).X, Mouse.GetPosition(this).Y);
            moAllowMoveWindow = true;
        }

        private void StackPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            moAllowMoveWindow = false;
        }

        private void StackPanel_MouseMove(object sender, MouseEventArgs e)
        {
            if (moAllowMoveWindow == false)
            {
                return;
            }
            Point location = new Point(
                this.Left + e.GetPosition(this).X - moDownPoint.X,
                this.Top + e.GetPosition(this).Y - moDownPoint.Y);
            this.Left = location.X;
            this.Top = location.Y;
        }

        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            GlobalSupportModele.OpenNewFrameCloseOwner(new frmWordsTranslation(), this);
        }

        private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            if (slider1.Value < 5)
            {
                slider1.Value = 0;
                lblLangDirect.Content = ProxyOption.PolEng;
                ProxyOption.LanguageDirection = ProxyOption.eLanguageDirection.PolEng;
            }
            else
            {
                slider1.Value = 10;
                lblLangDirect.Content = ProxyOption.EngPol;
                ProxyOption.LanguageDirection = ProxyOption.eLanguageDirection.EngPol;
            }
        }

        private void rdbWordAmount_CheckedChange(object sender, EventArgs e)
        {
            RadioButton rb = sender as RadioButton;
            if (rb != null)
            {
                if (rdbAllWords.IsChecked == true) ProxyOption.WordsAmount = ProxyOption.eWordsAmount.All;
                else if (this.rdbNotLearnedWords.IsChecked == true) ProxyOption.WordsAmount = ProxyOption.eWordsAmount.WithoutLearned;
                else if (this.rdbDificultWords.IsChecked == true) ProxyOption.WordsAmount = ProxyOption.eWordsAmount.DifficultOnly;
            }
        }

        private void btnEditWords_Click(object sender, RoutedEventArgs e)
        {
            throw new Exception("implement this button!");
        }

        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            GlobalSupportModele.OpenNewFrameCloseOwner(new frmRootUI(), this);
        }
    }
}
 